class Animal:
    def shout(self):
        print("animal is shouting")

class Cat(Animal):
    def shout(self):
        print("cat is shouting")


class Dog(Animal):
    def shout(self):
        print("dog is shouting")

d = Dog()
print("isinstance(d, Animal)", issubclass(Dog, Animal))
def animalShout(a):
    a.shout()

animalShout(Cat())
animalShout(Dog())
#animalShout(11)


a=2
b=3
print(a+b, a.__add__(b))


class Person():
    def __init__(self, name):
        self.name = name

    def __add__(self, other):
        if isinstance(other, Person):
            return '{0}--{1}'.format(self.name, other.name)
        else:
            return "不是同类，不同相加！"

    def __mul__(self, number):
        if isinstance(number, int):
            return self.name * number
        else:
            return "乘数必须为整数！"

tony = Person("tony wu")
wangZheng = Person("wangZheng")
print(tony + wangZheng)
print(tony * 3)

# print(tony - wangZheng)
'''
object 是所有类的父类
'''
print(Animal.__subclasses__())
print(Dog.__base__)
print(Dog.__bases__)
print(Dog.__mro__) # 往上的层次关系
print(Animal.__mro__)
print(object.__mro__)
print(type.__mro__)
print(type.__bases__)# type 是父类是 object
print(object.__class__) # object 类/图纸 是 type
# __class__ 是针对类与对象的关系
print(Dog().__class__)